<!DOCTYPE html>
<html class="ui-page-login">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/app.css" rel="stylesheet" />
		<link href="css/font-awesome.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/iconfont.css" />
		<style>
			.ui-page-login,
			body {
				width: 100%;
				height: 100%;
				margin: 0px;
				padding: 0px;
			}
			.mui-content{height: 100%;}
			.area {
				margin: 20px auto 0px auto;
			}
			
			.mui-input-group {
				margin-top: 0px;
			}
			
			.mui-input-group:first-child {
				m/*argin-top: 20px;*/
			}
			
			.mui-input-group label {
				width: 22%;
			}
			
			.mui-input-row label~input,
			.mui-input-row label~select,
			.mui-input-row label~textarea {
				width: 80%;
			}
			
			.mui-checkbox input[type=checkbox],
			.mui-radio input[type=radio] {
				top: 6px;
			}
			
			.mui-content-padded {
				margin-top: 25px;
			}
			
			.mui-btn {
				padding: 10px;
			}
			
			.link-area {
				display: block;
				margin-top: 25px;
				text-align: center;
			}
			
			.spliter {
				color: #bbb;
				padding: 0px 8px;
			}
			
			.mui-input-group .mui-input-row {
			    height: 60px;
			}
			.mui-input-row label{
				font-size:20px;
			}
			.mui-input-row .mui-input-clear~.mui-icon-clear{
				    font-size: 30px;
				    top: 14px;
			}
			
			input[type=text],input[type=select],input[type=password]{
				line-height: 30px;
				height:60px;
				font-size:20px;
			}
			.mui-input-row label {
			    font-family: 'Helvetica Neue',Helvetica,sans-serif;
			    line-height: 2;
			    float: left;
			    width: 20%;
			    padding: 11px 15px;
			}
		</style>

	</head>

	<body>
		<header class="mui-bar mui-bar-nav app-main-background-color">
			<h1 class="mui-title">登录</h1>
		</header>
		<div class="mui-content">
			<div style="margin-top: 30px; text-align: center;">
				<div>
					<img src="images/login-logo.png" style="height:4em;"/>
				</div>
				
			</div>
			<div class="mui-card" style="margin-top: 20px;">
			<form id='login-form' class="mui-input-group">
				<div class="mui-input-row">
					<label><i class="fa fa-user-o" aria-hidden="true"></i> </label>
					<input id='LOGIN_NAME' type="text" class="mui-input-clear mui-input" placeholder="请输入账号" value="">
				</div>
				<div class="mui-input-row">
					<label><span class="mui-icon iconfont icon-mimaxiugai"></label>
					<input id='LOGIN_PASS' type="password" class="mui-input-clear mui-input" placeholder="请输入密码" value="">
				</div>
			</form>
			</div>
			
			<div class="mui-content-padded">
				<button id='login' class="mui-btn mui-btn-block mui-btn-primary">登录</button>

			</div>
			<div class="mui-content-padded oauth-area">

			</div>
		</div>
		<script src="js/mui.min.js"></script>
		<script src="js/jquery-1.12.4.min.js"></script>

		<script src="js/mui.enterfocus.js"></script>
		<script src="js/app.js"></script>
		<script>
			(function($, doc) {
				$.init({
						statusBarBackground: '#F15A24',
				});
				$.plusReady(function() {
					plus.navigator.setStatusBarBackground("#F15A24");
					plus.screen.lockOrientation("portrait-primary");
					/*
					var mainPage = $.preload({
						"id": 'main',
						"url": 'index.html' 
					});
					*/
					
					var toMain = function() { 
						//$.fire(mainPage, 'show', null);
						//$.fire('main', 'show', null);
							var all = plus.webview.all();
							var current = plus.webview.currentWebview().id;
							for(var i=0;i<=all.length -1 ; i++ ){ 
							        if(all[i].id != plus.webview.getLaunchWebview().id){
							        	all[i].close();
							        	
							        }
					
							} 
							plus.webview.getLaunchWebview().reload(true);
							
//						setTimeout(function() {
//							$.openWindow({ 
//								id: 'index.html', 
//								url:'index.html',
//								show: {
//									aniShow: 'pop-in'
//								},
//								waiting: {
//									autoShow: false
//								}
//							});
//						}, 100);
					};
					// close splash
					setTimeout(function() {
						plus.navigator.closeSplashscreen();
					}, 600);
					//检查 "登录状态/锁屏状态" 结束
					var loginButton = doc.getElementById('login');
					var accountBox = doc.getElementById('LOGIN_NAME');
					var passwordBox = doc.getElementById('LOGIN_PASS');
					var imei =  plus.device.imei;
					loginButton.addEventListener('tap', function(event) {
						
						
						
						
						var loginInfo = {
							LOGIN_NAME: accountBox.value,
							LOGIN_PASS: passwordBox.value,
							IMEI      : imei
						};
						app.login(loginInfo, function(err) {
							if (err) {
								plus.nativeUI.toast(err);
								return false;
							}
							toMain();
						});
					});
/*					$.enterfocus('#login-form input', function() {
						$.trigger(loginButton, 'tap');
					}); */
				
					//
					var backButtonPress = 0;
					$.back = function(event) {
						backButtonPress++;
						if (backButtonPress > 1) { 
							plus.runtime.quit();
						} else {
							plus.nativeUI.toast('再按一次退出应用');
						}
						setTimeout(function() {
							backButtonPress = 0;
						}, 1000);
						return false;
					};
				});
			}(mui, document));
		</script>
	</body>

</html>